using System.Collections;
using System.ComponentModel.Design;

namespace VisualPureBasicIDE.FormDesigner.Implementations
{
    /// <summary>
    /// An implementation of dictionary service.
    /// </summary>
    public class DictionaryService : IDictionaryService
    {
        private readonly IDictionary _table;

        public DictionaryService()
        {
            _table = new Hashtable();
        }

        #region IDictionaryService Members

        public object GetValue(object key)
        {
            return _table[key];
        }

        public void SetValue(object key, object value)
        {
            _table[key] = value;
        }

        public object GetKey(object value)
        {
            object key = null;
            foreach (DictionaryEntry de in _table)
            {
                if (de.Value == value)
                {
                    key = de.Key;
                    break;
                }
            }
            return key;
        }

        #endregion
    }
}